Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposed spatial predicates over Geometry #366

Merged
merged 5 commits into from
Feb 10, 2023

Conversation

metasim
Copy link
Contributor

@metasim metasim commented Feb 5, 2023

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.

Partially addresses #306

cc: @thomas001

/// If OGR is built without the GEOS library, this function will always return `false`.
///
/// See: [`OGR_G_IsValid`](https://gdal.org/api/vector_c_api.html#_CPPv413OGR_G_IsValid12OGRGeometryH)
pub fn is_valid(&self) -> bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to determine if OGR was build with GEOS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdroenner I'll look into it. It might require build.rs calling into gdal_sys, which might be weird...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If build.rs can find gdalinfo in the path:

image

Copy link
Contributor Author

@metasim metasim Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdroenner I assume the implication of your question is that we'd want to optionally enable these GOES-dependent features? How about the case when someone compiles with GEOS support, but at runtime a different GDAL build is dynamically linked?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think we should gate these methods on GEOS. GDAL always has them, we should probably match that.

Copy link
Contributor Author

@metasim metasim Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably match that

WDYM? Assume GEOS is there? (Pretty sure you can build without it, although really rare).

If so, should I remove the caveat in these doc comments?

Copy link
Member

@lnicola lnicola Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant letting them compile and returning what GDAL returns.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want a feature gate. However there should be a method you can call (at runtime) to get the information if GEOS was build in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i guess its GDALVersionInfo and then looking if GEOS is in there. Maybe we can add a convenience method for that to our VersionInfo struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea. On it! 🤠

Comment on lines +96 to +99
/// Determine if GDAL is compiled with [GEOS](https://libgeos.org/) support.
pub fn has_geos() -> bool {
version_info("BUILD_INFO").contains("GEOS_ENABLED=YES")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdroenner @lnicola Should this be memoized somehow? I could imagine someone incorporating this into their logic (branching on capabilities) and this killing performance.

Copy link
Member

@lnicola lnicola Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary (I mean, what are you gonna do if these don't work?), but you can use https://docs.rs/once_cell/latest/once_cell/ if you want to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Should probably keep it simple for now. I'll update the docs to reference it and re-request a review for final approval.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: Plan on continuing the work of fleshing out the vector API in subsequent PRs.

@lnicola
Copy link
Member

lnicola commented Feb 9, 2023

bors d+

@bors
Copy link
Contributor

bors bot commented Feb 9, 2023

✌️ metasim can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@lnicola
Copy link
Member

lnicola commented Feb 10, 2023

@metasim this pretty much supersedes #174, do you want to add the remaining envelope and envelope_?3d, maybe in a follow-up PR? Just so we don't forget about them.

@metasim
Copy link
Contributor Author

metasim commented Feb 10, 2023

@lnicola

do you want to add the remaining envelope and envelope_?3d, maybe in a follow-up PR

Yes, I will do that. I wanted to replicate this pattern of files with additional but related inherent methods to make it easier to maintain, document and test. e.g. set-theoretic operations.

@metasim
Copy link
Contributor Author

metasim commented Feb 10, 2023

this pretty much supersedes #174,

Ooops, didn't realize this was out there!

@metasim
Copy link
Contributor Author

metasim commented Feb 10, 2023

bors r+

bors bot added a commit that referenced this pull request Feb 10, 2023
366: Exposed spatial predicates over `Geometry` r=metasim a=metasim

- [x] I agree to follow the project's [code of conduct](https://github.com/georust/gdal/blob/master/CODE_OF_CONDUCT.md).
- [X] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users.
---

Partially addresses #306 

cc: `@thomas001`

Co-authored-by: Simeon H.K. Fitch <[email protected]>
@bors
Copy link
Contributor

bors bot commented Feb 10, 2023

Build failed:

@metasim
Copy link
Contributor Author

metasim commented Feb 10, 2023

bors retry

@bors
Copy link
Contributor

bors bot commented Feb 10, 2023

@bors bors bot merged commit f6b2a16 into georust:master Feb 10, 2023
@metasim metasim deleted the feature/geom-preds branch February 11, 2023 15:24
@metasim metasim mentioned this pull request May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants